import {ElMessage, ElMessageBox} from 'element-plus'

/**
 * 如何调用，如下面调用案例
import {messafe,alertBox,confirmBox} from '@/utils/msgBox.js'
confirmBox('确认删除该标签吗？','确定',null).then(res => {
  alert("确定："+res)
}).catch(res => {
  alert("取消关闭："+res)
})
 * */

// 成功提示信息
export function message(options) {
  ElMessage({
    type: options.type,
    showClose: false,
    dangerouslyUseHTMLString: true,
    message: options.message,
  })
}

// 确定一个确定按钮alertBox
export function alertBox(option) {
  const options = option || {}
  return ElMessageBox.alert(options.message || '请输入提示信息', options.title || '提示', {
    type: options.type || 'warning',
    confirmButtonText: options.confirmButtonText || '确定',
    cancelButtonText: options.cancelButtonText || '取消',
    showCancelButton: options.showCancelButton || true,
    cancelButtonClass: 'cancelBtn',
    dangerouslyUseHTMLString: true,
    customClass: 'confrim-alter'
  })
}

// 确定一个输入框
export function promptInput(option) {
  const options = option || {}
  return ElMessageBox.prompt(options.message || '请输入提示信息', options.title || '提示', {
    type: options.type || 'warning',
    confirmButtonText: options.confirmButtonText || '确定',
    cancelButtonText: options.cancelButtonText || '取消',
    showCancelButton: options.showCancelButton || true,
    cancelButtonClass: 'cancelBtn',
    dangerouslyUseHTMLString: true,
    customClass: 'confrim-alter'
  })
}

// 确定取消;是否按钮弹出框
export function confirmBox(option) {
  const options = option || {}
  return ElMessageBox.confirm(options.message || '请输入提示信息', options.title || '提示', {
    type: options.type || 'warning',
    confirmButtonText: options.confirmButtonText || '确定',
    cancelButtonText: options.cancelButtonText || '取消',
    showCancelButton: options.showCancelButton || true,
    cancelButtonClass: 'cancelBtn',
    dangerouslyUseHTMLString: true,
    customClass: 'confrim-alter',
    closeOnClickModal: false,
    closeOnPressEscape: false
  })
}
